<%--
  Created by IntelliJ IDEA.
  User: HP
  Date: 2019/9/9
  Time: 13:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="layui/layui.js"></script>
    <script src="js/jquery-1.12.4.js"></script>

</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">layui 后台布局</div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                    贤心
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="">退了</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">科室管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" onclick="addTab('department.jsp',1)">科室展示</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">患者管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" onclick="addTab('patient.jsp',2)">患者展示</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">药品管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" onclick="addTab('drug.jsp',3)">药品展示</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item">
                    <a href="javascript:;">审核管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" onclick="addTab('exam.jsp',4)">审核展示</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item">
                    <a href="javascript:;">文件管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" onclick="addTab('files.jsp',5)">文件展示</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item">
                    <a href="javascript:;">分诊管理</a>
                    <dl class="layui-nav-child">
                        <dd><div id="myTree"></div></dd>
                    </dl>
                </li>
                <li class="layui-nav-item"><a href="">其他</a></li>
            </ul>
        </div>
    </div>

    <div class="layui-body">

        <!-- 内容主体区域 -->
        <div style="padding:15px">
            <div class="layui-tab layui-tab-brief layui-tab-card" lay-allowClose="true" lay-filter="myTab">
                <ul class="layui-tab-title">
                    <li class="layui-this">欢迎页</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">欢迎使用..xxxx</div>
                </div>
            </div>
        </div>

    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 底部固定区域
    </div>
</div>
<script>
    $(function(){
        $.ajax({
            url:"${pageContext.request.contextPath}/selectTree",
            success:function(data){
                layui.use(['tree','element'], function(){
                    var tree = layui.tree;
                    //渲染
                    var inst1 = tree.render({
                        elem: '#myTree' //绑定元素
                        ,data:data
                        ,click:function(obj){
                            console.log(obj.data)
                            //在tabs里面添加一个选项卡
                            var element = layui.element;
                            if($("li[lay-id='"+obj.data.id+"']").length==0){
                                element.tabAdd('myTab', {
                                    title: obj.data.title
                                    ,content: '<iframe src="/jsp/TriageRet.jsp?departmentId='+obj.data.id+'" height="100%" width="100%"></iframe>' //支持传入html
                                    ,id: obj.data.id
                                });
                            }

                            element.tabChange("myTab",obj.data.id)
                        }
                    });
                });
            }
        })
    });

    function addTab(jspName,id) {
        layui.use('element', function(){

            //在tabs里面添加一个选项卡
            var element = layui.element;

            element.tabAdd('myTab', {
                title: jspName
                ,content: '<iframe src=/hospitalSystem/'+jspName +' height="100%" width="100%"></iframe>' //支持传入html
                ,id: id
            });

            element.tabChange("myTab",id)
        });
    }

</script>
</body>
</html>







